package eightDataType.mStr;

import org.apache.log4j.Logger;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;

/**
 * @author Ajie
 * @date 2023/8/15
 * @function
 */
public class URL_Str_Encode {
    private static final Logger logger = Logger.getLogger(URL_Str_Encode.class);

    public static void main(String[] args) {
        stringEncode();
    }

    //编码
    private static void stringEncode() {
        try {
            String encode3 = URLEncoder.encode("华北", "utf-8");
            System.out.println(encode3 + "    " + "utf-8");
            System.out.println("URL_Str_Encode:stringEncode:decode:"+ URLDecoder.decode(encode3,"utf-8"));

            String encode2 = URLEncoder.encode("华北", "gb2312");
            System.out.println(encode2 + "    " + "gb2312");
            System.out.println("URL_Str_Encode:stringEncode:"+URLDecoder.decode(encode2,"gb2312"));

            String encode = URLEncoder.encode("我");
            System.out.println(encode+"  default");
            System.out.println("URL_Str_Encode:stringEncode:"+URLDecoder.decode(encode));
            System.out.println("".length());
        } catch (UnsupportedEncodingException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }


    }
}
